<?php

/**
 * Factura form base class.
 *
 * @method Factura getObject() Returns the current form's model object
 *
 * @package    saveenergy
 * @subpackage form
 * @author     0
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseFacturaForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'numeroFactura'   => new sfWidgetFormInputText(),
      'fechaEmision'    => new sfWidgetFormDate(),
      'contrato_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Contrato'), 'add_empty' => false)),
      'inicioPeriodo'   => new sfWidgetFormDate(),
      'finPeriodo'      => new sfWidgetFormDate(),
      'importe'         => new sfWidgetFormInputText(),
      'path'            => new sfWidgetFormInputText(),
      'lecturaAnterior' => new sfWidgetFormInputText(),
      'lecturaActual'   => new sfWidgetFormInputText(),
      'energiaReactiva' => new sfWidgetFormInputText(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'numeroFactura'   => new sfValidatorString(array('max_length' => 50)),
      'fechaEmision'    => new sfValidatorDate(),
      'contrato_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Contrato'))),
      'inicioPeriodo'   => new sfValidatorDate(),
      'finPeriodo'      => new sfValidatorDate(),
      'importe'         => new sfValidatorPass(array('required' => false)),
      'path'            => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'lecturaAnterior' => new sfValidatorPass(array('required' => false)),
      'lecturaActual'   => new sfValidatorPass(array('required' => false)),
      'energiaReactiva' => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('factura[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Factura';
  }

}
